<?php
class Admin_Model_Parameter extends Zend_Db_Table{
	protected $_name = 'parameter';
	protected $_primary = 'idParameter';
	/* Link tham khao : http://framework.zend.com/manual/en/zend.db.table.html */
	////////////
	/* select*/
	//////////
	public function selectSetting($code)
	{// co dung
		$client = new Zend_Rest_Client(HTTP_SERVICE);
		$return = $client->restGet("/parameter/route/selectSetting/code/".$code);
		$return = json_decode(json_encode((array) simplexml_load_string($return->getBody())),1);
		
		for ($i=0;$i <count($return);$i++)
				$data[$i] = $return['row_'.$i];
		
		return $data;		
	}
	
	////////////
	/* insert*/
	//////////
	public function insertSetting($data)
	{// co dung
		$data['route'] = "insertSetting";
		$client = new Zend_Rest_Client(HTTP_SERVICE);
		$return = $client->restPost("/parameter", $data);

		return $return->getBody();		
	}
	////////////
	/* update*/
	//////////
	public function updateSetting($data)
	{// co dung
		$client = new Zend_Rest_Client(HTTP_SERVICE);
		$return = $client->restPut("/parameter/route/updateSetting/name/".urlencode($data['parameter_name'])."/value/".urlencode($data['parameter_value']));
		return $return->getBody();		
	}
}